#!/usr/bin/env python
from cmath import *
from mpmath import *


def post_process(results):
	ratio = [ a[-1] for a in results[1:]]
	max_ratio = max(ratio)
	max_ratio_time = results[ratio.index(max_ratio) + 1][0]
	up_population = [ a[1] for a in results[1:]]
	max_up_population = max(up_population)
	max_up_population_time = results[up_population.index(max_up_population) + 1][0]
	decoherence = [ a[-2] for a in results[1:]]
	min_decoherence = min(decoherence)
	min_decoherence_time = results[decoherence.index(min_decoherence) + 1][0]
	return [max_ratio, max_ratio_time, max_up_population, max_up_population_time, min_decoherence, min_decoherence_time]


def static_sum(results, statics):
	temp = results[1:][:]
	statics += matrix(temp)
	return statics


def static_average(statics, iteration):
	return 1.0 * statics / iteration

		
